<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Loader;
use app\common\model\Manager;

class Login extends Controller
{

    public function __construct()
    {
        parent::__construct();
    }

    public function dologin()
    {
        $input = input();

        if (!$input['email'] || !$input['password']) {
            return returnJson(1, '请填写用户名和密码');
        }

        $manager = Manager::getOne([
            'email' => $input['email']
        ]);

        if (!$manager || createPassword($input['password']) != $manager['password']) {
            return returnJson(1, '密码错误');
        }

        return returnJson(0, '登陆成功', array('token' => $manager['id']));
    }



}
